package edu.cuit.svsp.handler;

import edu.cuit.svsp.exception.AccountOrPasswordErrorException;
import edu.cuit.svsp.request.ResponseResult;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @className: GloberExceptionHandler
 * @author: pjy
 * @description: 全局异常处理
 * @date: 2024/7/2
 */
@RestControllerAdvice
public class GloberExceptionHandler {
    // 处理账号密码错误
    @ExceptionHandler(AccountOrPasswordErrorException.class)
    public ResponseResult<String> accountOrPasswordErrorException(AccountOrPasswordErrorException e) {
        System.out.println("捕获账号登录异常");
        return new ResponseResult<>(HttpStatus.UNAUTHORIZED.value(),e.getMessage(),null);
    }
}
